import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int w=sc.nextInt();//每组价格上限
        int n= sc.nextInt();//纪念品数量
        int[] price= new int[n];
        for (int i = 0; i < n; i++) {
            price[i]= sc.nextInt();
        }
        Arrays.sort(price);
        int left=0;
        int right=n-1;
        int group=0;
        while(left<=right){
            if(price[left]+price[right]<=w){
                left++;
                right--;
                group++;
            }else {
                right--;
                group++;
            }
        }
        System.out.println(group);//分组数量
    }
}
